March 17, 2007 3:30 PM
I am creating this notebook by opening the previous session and deleting most of the cells, but keeping those that produced a graph of a simple quadratic function.

My goal for this session is two-fold:
     (1) to redraw the graph so the x-axis passes through the point y = 0.
     
     (2) use a different format for the overall file.

Basic plotting is accomplished with the Plot command. The basic syntax is Plot[expression, {x, a, b}] which will plot the values of the expression where x takes values from a to b.

Plot[x^2 + 5, {x, -5, 5}]

[Graphics:HTMLFiles/index_2.gif]

⁃Graphics⁃

Typing a semicolon after the command suppresses the Output line.

Plot[x^2 + 5, {x, -5, 5}] ;

[Graphics:HTMLFiles/index_5.gif]

One often wants to superimpose two or more graphs on the same diagram. Suppose f1 and f2 are two functions.

f1 = x^2 + 5

5 + x^2

f2 = 3x - 2

-2 + 3 x

Plot[{f1, f2}, {x, -5, 5}] ;

[Graphics:HTMLFiles/index_11.gif]

Suppose one wants to have the lines in different colors.

p1 = Plot[f1, {x, -5, 5}, PlotStyleRed] ;

[Graphics:HTMLFiles/index_13.gif]

p2 = Plot[f2, {x, -5, 5}, PlotStyleBlue] ;

[Graphics:HTMLFiles/index_15.gif]

Show[p1, p2] ;

[Graphics:HTMLFiles/index_17.gif]

Mathematica has 30 different options for the Plot command. So far we have seen one, PlotStyle, which can be used to specify the color of the curve.
Another useful option is called AspectRatio. This controls the ratio of the height to the width of the plot.
     If it is set to 1/GoldenRatio then one sees an aesthetically pleasing form.
     If it is set to Automatic then both axes are set to the same scale.
     If one wants to avoid difficulties when Automatic gives too narrow a plot, try using PlotRange and restrict the range to smaller values.

p3 = Plot[x^2 + 3, {x, -10, 10}, PlotStyleRed] ;

[Graphics:HTMLFiles/index_19.gif]

p3 = Plot[x^2 + 3, {x, -10, 10}, PlotStyleRed, AspectRatio1/GoldenRatio] ;

[Graphics:HTMLFiles/index_21.gif]

p3 = Plot[x^2 + 3, {x, -10, 10}, PlotStyleRed, AspectRatioAutomatic] ;

[Graphics:HTMLFiles/index_23.gif]

p3 = Plot[x^2 + 3, {x, -10, 10}, PlotStyleRed, AspectRatioAutomatic, PlotRange {0, 20}] ;

[Graphics:HTMLFiles/index_25.gif]

Setting the AspectRatio to Automatic puts both axes on the same scale. In this case that ensures that the x-axis passes through the origin. Setting the PlotRange to a smaller value helps one see the graph more clearly for the smaller values.

p3 = Plot[x^2 + 3, {x, -10, 10}, PlotStyleRed, AspectRatioAutomatic, PlotRange {0, 10}] ;

[Graphics:HTMLFiles/index_27.gif]

Now to see if I can change the overall style of the entire session.
The appropriate command is Format -> StyleSheet -> Classroom
3:50 PM This turned out to be a much shorted session than I expected (only 20 minutes).


Created by Mathematica  (March 17, 2007) Valid XHTML 1.1!